package com.jz.community.moduleshopping.refund.task;

import android.app.Activity;

import com.jz.community.basecomm.constant.Constant;
import com.jz.community.basecomm.net.OkHttpUtil;
import com.jz.community.basecomm.task.ITaskCallbackListener;
import com.jz.community.basecomm.task.RxTask;
import com.jz.community.commview.view.widget.ProgressDialogManager;

import java.util.HashMap;

public class SubmitRefundTask extends RxTask<String, Integer, String> {

    private Activity activity;
    private ITaskCallbackListener taskListener;

    public SubmitRefundTask(Activity activity, ITaskCallbackListener taskListener) {
        super(activity);
        this.activity = activity;
        this.taskListener = taskListener;
    }

    @Override
    protected String doInBackground(String... params) {
        String result = OkHttpUtil.post(Constant.ORDER_SHARE_REFUND, getParam(params[0], params[1], params[2], params[3]),true);
        return result;
    }

    @Override
    protected void onPostExecute(String result) {
        // 执行结果回调函数
        taskListener.doTaskComplete(result);
        ProgressDialogManager.dismissProgressDialog();
        super.onPostExecute(result);
    }

    @Override
    protected void onPreExecute() {
        ProgressDialogManager.showDialog(activity);
        super.onPreExecute();
    }

    @Override
    protected void onCancelled() {
        super.onCancelled();
    }

    private HashMap<String, Object> getParam(String orderId, String describe, String image, String goodsCount) {
        HashMap<String, Object> params = new HashMap<>();
        params.put("orderId", orderId);
        params.put("describe", describe);
        params.put("image", image);
        params.put("goodsCount", goodsCount);
        return params;
    }

}
